package com.wenhai.spring.bean.factory;

import com.wenhai.xiaomage.spring.ioc.overview.dependency.domain.User;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class DefaultUserFactory implements UserFactory<User>, InitializingBean, DisposableBean {


    // 1. 基于@PostConstruct
    @PostConstruct
    public void init(){
        System.out.println("@PostConstruct:UserFactory 初始化中");

    }

    public void initMethod(){
        System.out.println("initMethod:UserFactory 初始化中");

    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet():UserFactory 初始化中");
    }


    @PreDestroy
    public void destroyAnnotation(){
        System.out.println("@PreDestroy 销毁");

    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean#destroy方法 销毁");

    }


    public void destroyCustomDestroyMethod() {
        System.out.println("自定义#destroy方法 销毁");
    }

}
